TARGETS = bfencrypt bfencrypt_openmp bfdecrypt bfdecrypt_openmp aesencrypt aesencrypt_openmp aesdecrypt aesdecrypt_openmp md5encrypt md5encrypt_openmp gen_key keccak keccak_openmp
SRCS = bfencrypt.c bfdecrypt.c blowfish.c aesencrypt.c aesdecrypt.c aes.c md5encrypt.c md5.c gen_key.c keccak.c
#PAR_SRCS = bfencrypt_parallel.c blowfish_parallel.c aesencrypt_parallel.c aes_parallel.c md5encrypt_parallel.c md5_parallel.c
OMP_SRCS = blowfish_openmp.c bfencrypt_openmp.c bfdecrypt_openmp.c aesencrypt_openmp.c aes_openmp.c aesdecrypt_openmp.c md5_openmp.c md5encrypt_openmp.c keccak_openmp.c
OBJECTS = ${SRCS.c=.o}
#PAR_OBJECTS = ${PAR_SRCS.c=.o}
#OMP_OBJECTS = ${OMP_SRCS.c=.o}
CC = gcc
MPICC = mpicc
CCFLAGS = -O3 -Wall -fopenmp
LDFLAGS = -fopenmp
LIBS    = 

.PHONY: all clean distclean 
all:: $(TARGETS)

%.o: %.c
	${CC} ${CCFLAGS} -o $@ -c $<
	#$(if $(filter $<,${PAR_SRCS}),${MPICC} ${CCFLAGS} -o $@ -c $<,	$(if $(filter $<,${OMP_SRCS}), ${CC} ${CCFLAGS} -o $@ -c $<, ${CC} ${CCFLAGS} -o $@ -c $<))

#$(PAR_OBJECTS): %.o: %.c
#	echo "asdf"
#	echo "asdf"
#	${MPICC} ${CCFLAGS} -o $@ -c $< 

bfencrypt: bfencrypt.o blowfish.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

bfencrypt_parallel: bfencrypt_parallel.o blowfish_parallel.o
	${MPICC} ${LDFLAGS} -o $@ $^ ${LIBS} 

bfencrypt_openmp: bfencrypt_openmp.o blowfish_openmp.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

bfdecrypt: bfdecrypt.o blowfish.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

bfdecrypt_openmp: bfdecrypt_openmp.o blowfish_openmp.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

aesencrypt: aesencrypt.o aes.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

aesencrypt_parallel: aesencrypt_parallel.o aes_parallel.o
	${MPICC} ${LDFLAGS} -o $@ $^ ${LIBS} 

aesencrypt_openmp: aesencrypt_openmp.o aes_openmp.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

aesdecrypt: aesdecrypt.o aes.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

aesdecrypt_openmp: aesdecrypt_openmp.o aes_openmp.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

md5encrypt: md5encrypt.o md5.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} -lm

md5encrypt_parallel: md5encrypt_parallel.o md5_parallel.o
	${MPICC} ${LDFLAGS} -o $@ $^ ${LIBS} 

md5encrypt_openmp: md5encrypt_openmp.o md5_openmp.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} -lm

gen_key: gen_key.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

keccak: keccak.o
	${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 

keccak_openmp: keccak_openmp.o
	${CC} ${LDFLAGS} -g -o $@ $^ ${LIBS} 

clean:: 
	-rm -f *~ *.o ${TARGETS} 

distclean:: clean
